package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mappers.BlackListMapper;
import com.tanhua.model.domain.UserInfo;
import com.tanhua.service.BlackListApi;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class BlackListApiImpl implements BlackListApi {

    @Autowired
    private BlackListMapper blackListMapper;

    /**
     * 分页查询黑名单列表
     * @param id
     * @param page1
     * @return
     */
    @Override
    public IPage<UserInfo> getPageUser(Long id, Page page1) {
        IPage<UserInfo> page = blackListMapper.getByUserIdBlack(id, page1);
        return page;
    }

    /**
     * 删除黑名单用户
     * @param userId 用户id
     * @param blaceUserId 黑名单用户id
     */
    @Override
    public void delectBlack(Long userId, Long blaceUserId) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("user_id", userId);
        qw.eq("black_user_id", blaceUserId);
        blackListMapper.delete(qw);
    }
}